package com.tencent.welink.iot;

public class LoginData implements Cloneable {
    //{"keyUsefulTime":86400,"httpToken":"7ed10538-4c31-44ab-9fa2-a66dc88ce16b","ran":"p9BNiPDq2XJmViXM","ts":1591796680642}
    public int keyUsefulTime;
    public String httpToken;
    public String ran;
    public long ts;
    public String sm4IV;
    public String lastRan;
    public String lastSm4IV;
    public String lastHttpToken;
    public long time;
    private Object lock = new Object();
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public LoginData load(){
        synchronized (lock){
            try {
                return (LoginData)clone();
            }catch (Exception e) {
                return null;
            }
        }
    }
    public void set(LoginData loginData) {
        synchronized (lock) {
            this.keyUsefulTime = loginData.keyUsefulTime;
            this.httpToken = loginData.httpToken;
            this.ran = loginData.ran;
            this.ts = loginData.ts;
            this.sm4IV = loginData.sm4IV;
            this.time = System.currentTimeMillis();
        }
    }
}
